package com.egao.orderB.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
import com.egao.orderB.biz.DriverOilRechargeBiz;
import com.egao.orderB.entity.DriverOilRecharge;
import com.egao.orderB.service.DriverOilRechargeService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

//import com.egao.orderB.mapper.DriverOilRechargeMapper;
//import javax.transaction.Transactional;

/**
 * 油卡服务实现类
 * @author : Doman
 * @date : 2021-07-07 16:53:48
 * @version ：1.0
 */
@Service
public class DriverOilRechargeServiceImpl /*extends ServiceImpl<DriverOilRechargeMapper, DriverOilRecharge> */implements DriverOilRechargeService {

	@Autowired
	private DriverOilRechargeBiz driverOilRechargeBiz;

    /**
    @Override
    public PageResult<DriverOilRecharge> listPage(PageParam<DriverOilRecharge> page) {
        List<DriverOilRecharge> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<DriverOilRecharge> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, DriverOilRecharge driverOilRecharge, User loginUser)  throws Exception{
        return driverOilRechargeBiz.list(page,driverOilRecharge,loginUser);
    }

    @Override
    public JsonResult list(DriverOilRecharge driverOilRecharge, User loginUser) {
        return JsonResult.ok().setData(driverOilRechargeBiz.list(driverOilRecharge,loginUser));
    }

    @Override
    public JsonResult getById(DriverOilRecharge driverOilRecharge) {
        return JsonResult.ok().setData(driverOilRechargeBiz.getById(driverOilRecharge));
    }

    @Transactional
    @Override
    public JsonResult save(DriverOilRecharge driverOilRecharge, User loginUser) {
        if (driverOilRechargeBiz.save(driverOilRecharge, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(DriverOilRecharge driverOilRecharge, User loginUser) {
        if (driverOilRechargeBiz.update(driverOilRecharge, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(DriverOilRecharge driverOilRecharge, User loginUser) {
        if (driverOilRechargeBiz.remove(driverOilRecharge, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
